<?php

require(__META_CONTROLS_GEN__ . '/UserDataGridGen.class.php');

/**
 * This is the "Meta" DataGrid customizable subclass for the List functionality
 * of the User class.  This code-generated class extends
 * from the generated Meta DataGrid class which contains a QDataGrid class which
 * can be used by any QForm or QPanel, listing a collection of User
 * objects.  It includes functionality to perform pagination and sorting on columns.
 *
 * To take advantage of some (or all) of these control objects, you
 * must create an instance of this DataGrid in a QForm or QPanel.
 *
 * This file is intended to be modified.  Subsequent code regenerations will NOT modify
 * or overwrite this file.
 *
 * @package flx_qcubed
 * @subpackage MetaControls
 *
 */
class UserDataGrid extends UserDataGridGen {

    public function MetaAddEditLinkColumn($strLinkUrl, $strLinkHtml = 'Edit', $strLinkCssClass = 'btn', $strColumnTitle = 'Edit', $intArgumentType = QMetaControlArgumentType::PathInfo) {
        switch ($intArgumentType) {
            case QMetaControlArgumentType::QueryString:
                $strLinkUrl .= (strpos($strLinkUrl, '?') !== false ? '&' : '?') . 'intId=<?=urlencode($_ITEM->Id)?>';
                break;
            case QMetaControlArgumentType::PathInfo:
                $strLinkUrl .= '/<?=urlencode($_ITEM->Id)?>';
                break;
            default:
                throw new QCallerException('Unable to pass arguments with this intArgumentType: ' . $intArgumentType);
        }

        $strHtml = '<a class="' . $strLinkCssClass . '" href="' . $strLinkUrl . '">' . $strLinkHtml . '</a>';
        $colEditColumn = new QDataGridColumn($strColumnTitle, $strHtml, 'HtmlEntities=False');
        $this->AddColumn($colEditColumn);
        return $colEditColumn;
    }

    public function MetaAddEditProxyColumn(QControlProxy $pxyControl, $strLinkHtml = 'Edit', $strLinkCssClass = 'btn', $strColumnTitle = 'Edit') {
        $strHtml = '<a class="' . $strLinkCssClass . '" href="javascript:void(0);" <?= $_FORM->GetControl("' . $pxyControl->ControlId . '")->RenderAsEvents($_ITEM->Id, false); ?>>' . $strLinkHtml . '</a>';
        $colEditColumn = new QDataGridColumn($strColumnTitle, $strHtml, 'HtmlEntities=False');
        $this->AddColumn($colEditColumn);
        return $colEditColumn;
    }

    protected function GetPaginatorRowHtml($objPaginator) {
        return null;
    }

    protected function GetFooterRowHtml() {

        $footer = '<div class="pull-left">';
        if ($this->TotalItemCount > 0) {
            $intStart = (($this->PageNumber - 1) * $this->ItemsPerPage) + 1;
            $intEnd = $intStart + count($this->DataSource) - 1;
            $footer .= sprintf($this->strLabelForPaginated, $this->strNounPlural, $intStart, $intEnd, $this->TotalItemCount);
        } else {
            $intCount = count($this->objDataSource);
            if ($intCount == 0)
                $footer .= sprintf($this->strLabelForNoneFound, $this->strNounPlural);
            else if ($intCount == 1)
                $footer .= sprintf($this->strLabelForOneFound, $this->strNoun);
            else
                $footer .= sprintf($this->strLabelForMultipleFound, $intCount, $this->strNounPlural);
        }
        $footer .= '</div>';

        $footer .= '<div class="pull-right">';
        $footer .= $this->objPaginator->Render(false, 'CssClass="pagination"');
        $footer .= '</div>';

        if ($this->objPaginator)
            return sprintf('<tr><td colspan="%s">%s</td></tr>', count($this->objColumnArray), $footer);
    }

}

?>